"""“
登录页面
"""
from selenium.webdriver.common.by import By
from page.base_page import BasePage

class LoginPage(BasePage):
    url="/crm/index.php?m=user&a=login"
    #定位器
    username_locator=(By.NAME,"name")
    password_locator=(By.NAME,"password")
    login_locator=(By.NAME,"submit")


    # 输入用户名
    def input_username(self,username):
        self.driver.find_element(*self.username_locator).send_keys(username)

    # 输入密码
    def input_password(self,password):
        self.driver.find_element(*self.password_locator).send_keys(password)

    # 点击登录
    def click_btn(self):
        self.driver.find_element(*self.login_locator).click()

    # 返回当前页面url
    def open(self):
        return self.driver.get(self.url)

    # 完成登录操作
    def login(self, username, password):
        self.open()
        self.input_username(username)
        self.input_password(password)
        self.click_btn()
